1. Field of the Invention
The present invention generally relates to computer graphics, and more specifically relates to rendering of computer images on a display screen.
2. Description of the Related Art
Many computer-generated images contain points. The points may represent vertices of polygons. They may be rain, snow, or any other particles. Illustrated on the display, or can be part of large features, such runway lights. For high quality images, the points need to appear circular. The motion of the points should be smooth, and the color of a point should be uniform.
Most graphics application program interfaces (APIs), such as OpenGL, have a method to draw points as squares. This method of rendering is usually referred to as non-smooth or non-antialiased points. The method can be used to quickly draw points. However, the rendered points are not circular on the display. Further, as the points move on the display, they jump from one pixel to the next, making them appear to shake or jitter.
To overcome the limitations of non-smooth points, most APIs define one or more techniques for drawing smooth points. These techniques require that the point have a circular shape, and that points be sampled multiple times for each pixel they touch. Sampling multiple times smoothes the edges of the point and reduces the jitter as the point moves. However, this smoothing increases the amount of processing required to draw each point.
Several methods are used to draw smooth points. One method computes the sum of squares per sample. In this method, a sample that is inside a point meets the following condition:r2>=(x−xp)2+(y−yp)2,
where:
r=the radius of the point,
(xp, yp)=the position of the center of the point,
(x, y)=the position of the sample.
Each sample evaluation requires two subtracts, two multiplies, one add, and one magnitude compare. Further, the equation is not linear, making an iterative evaluation more difficult. It should be noted that while triangle edge evaluation is a common operation in graphics system, this equation is not of the form used to evaluate triangle edges, so additional hardware is required.
Another method to draw smooth points approximates points using polygons. A circular point can be approximated with a polygon. Adding more sides to the polygon makes the approximation more accurate. Each sample point inside the bounding box of the point needs to be checked to see if it is inside the polygon. This requires an edge evaluation of the form:(x−xn0)*(yn1−yn0)−(y−yn0)*(xn1−xn0)>=0;
where:
(xn0, yn0) and (xn1, yn1) are the endpoints of the nth edge of the polygon,
(x, y) is the position of the sample point.
This equation is of the form used to evaluate triangle edges. Most graphics hardware supports three or four edge evaluators to handle triangles or quadrangles. Larger points need more than four sides in the polygon to reduce visual artifacts, and therefore, additional hardware or processing is required to evaluate the polygons.
A third method to draw smooth points approximates points using tesselated polygons. The polygon used to approximate a circular point can be divided in to small polygons. The process is called tessellation. Typically, polygons are divided in to triangles. However, using triangles is inefficient, and can cause visual artifacts. A triangle may have as many as two edges that are interior to the polygon. All edges are evaluated, but the interior edges do not determine the final coverage. In addition, each interior edge is common to two triangles and is wastefully evaluated twice.
A pixel's final value for rendering is the sum of the coverage of all triangles that touch it. A pixel may have multiple triangles from the polygon that touch it. Inaccuracies in the math used to sum the coverage of the triangles may result in a value that is too high or too low. In addition, the application may select a different blend function, resulting in incorrect pixel values.
In the prior art method of FIG. 1, each triangle 102 has two interior edges 104. Each interior edge 106 is common to two triangles. If each triangle 102 is processed individually, then each of the interior edges 104 is evaluated twice. However, the coverage for the polygon 108 is determined only by the exterior edges 110. Some pixels are intersected by more than one triangle 102. The center most pixel is intersected by eight triangles 102, but no exterior edges 110. If each triangle 102 is processed individually, then the center pixel will be written eight times. Each time the center pixel is written, the intensity will be ⅛th the intensity of the point. If pixel's colors are stored as 8 bit values, and the desired value of the point is 124, then the center pixel will have a value of 8*int(124/8)=120, or 8*int(124/8+½)=128, depending the implementation.
As shown above, the existing methods either require additional hardware for rendering points or present inconsistent results.